cssnode: Delay getting the parent style until we need it
authorTimm Bäder <mail@baedert.org>
Tue, 10 Oct 2017 19:54:53 +0000 (21:54 +0200)
committerTimm Bäder <mail@baedert.org>
Wed, 11 Oct 2017 05:35:09 +0000 (07:35 +0200)
There's an early return before.

Look at all those saved cycles.

gtk/gtkcssnode.c

index 94139cd51028b2ef270c40834b98275390cba05c..95a687ffacc7df2d23413441678da1d58df41946 100644 (file)
@@ -361,12 +361,13 @@ gtk_css_node_create_style (GtkCssNode *cssnode)
   GtkCssStyle *style;
 
   decl = gtk_css_node_get_declaration (cssnode);
-  parent = cssnode->parent ? cssnode->parent->style : NULL;
 
   style = lookup_in_global_parent_cache (cssnode, decl);
   if (style)
     return g_object_ref (style);
 
+  parent = cssnode->parent ? cssnode->parent->style : NULL;
+
   if (gtk_css_node_init_matcher (cssnode, &matcher))
     style = gtk_css_static_style_new_compute (gtk_css_node_get_style_provider (cssnode),
                                               &matcher,